<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title><?php echo PAGE_TITLE . " &raquo; " . $pageTitle = $pageTitle == "" ? PAGE_TITLE : $pageTitle; ?></title>

        <style type='text/css' media='all'>@import url('<?php echo base_url(); ?>style/layout/style_1.css');</style>
        <link rel="stylesheet" href="<?php echo base_url(); ?>style/layout/style_1.css" type="text/css" />

        <style type='text/css' media='all'>@import url('<?php echo base_url(); ?>style/layout/style.css');</style>
        <link rel="stylesheet" href="<?php echo base_url(); ?>style/layout/style.css" type="text/css" />

        <link rel="SHORTCUT ICON" href="<?php echo base_url(); ?>style/layout/favicon.ico" />
        <script type="text/javascript" src="<?php echo base_url(); ?>style/layout/nav.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>style/layout/prototype.lite.js"></script>
        <script src="<?php echo base_url(); ?>style/component/js/jquery-1.4.4.js" type="text/javascript"></script>
        <script src="<?php echo base_url(); ?>style/component/js/global.js" type="text/javascript"></script>
        <script src="<?php echo base_url(); ?>style/component/jquery-ui/jquery.js" type="text/javascript"></script>
        <script src="<?php echo base_url(); ?>style/component/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
        <script type="text/javascript">var GB_ROOT_DIR = "<?php echo base_url(); ?>style/component/greybox/";</script>
        <script type="text/javascript" src="<?php echo base_url(); ?>style/component/greybox/AJS.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>style/component/greybox/AJS_fx.js"></script>
        <script type="text/javascript" src="<?php echo base_url(); ?>style/component/greybox/gb_scripts.js"></script>
        <script src="<?php echo base_url(); ?>style/component/jquery.timer.js" type="text/javascript"></script>
        <script src="<?php echo base_url(); ?>style/component/adl.util.js" type="text/javascript"></script>
        <link href="<?php echo base_url(); ?>style/component/greybox/gb_styles.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="<?php echo base_url() ?>style/component/tiny_mce/tiny_mce.js"></script>
        <script language="javascript" type="text/javascript">
            function limitText(limitField, limitCount, limitNum) {
                if (limitField.value.length > limitNum) {
                    limitField.value = limitField.value.substring(0, limitNum);
                } else {
                    limitCount.value = limitNum - limitField.value.length;
                }
            }
        </script>
        <meta http-equiv='expires' content='-1' />
        <meta http-equiv= 'pragma' content='no-cache' />
        <meta name='robots' content='all' />
        <meta name='author' content='ASP' />
        <meta name='description' content='ASP Control Panel' />
    </head>

    <body class="bb">
        <?php
        $parent_menus = $this->db->query("select * from mt_menu where id_menu_induk is null and is_active = 1 ORDER BY urutan");
        ?>
        <style>
            html { height: 100%; }
            body { min-height: 100%; }
            .block-box{top:0px; left:0px; display:none; position:absolute; width:100%; height:100%; z-index: 9000; opacity: 0.5; background-color: #000}
            .menu-box{display:none; position:absolute; left: 5%; background-color: #fff; box-shadow: 0px 0px 10px #fff; border:1px solid #aaa; border-radius:5px; width:90%; height:90%; top:5%; opacity: 1 !important; z-index: 9100;}
            .help-box{display:none; position:absolute; left: 5%; background-color: #fff; box-shadow: 0px 0px 10px #fff; border:1px solid #aaa; border-radius:5px; width:90%; height:90%; top:5%; opacity: 1 !important; z-index: 9100;}
            .inner-menu-box{}
            .band-title{float:left; margin-top:2px; font-weight: bold; font-size: 16px; color: #666; text-shadow: -1px -1px 1px #fff, 1px 1px 1px #fff;}
            .inner-band-box{box-shadow:0px 0px 3px #aaa; background-color: #F1F1F1; padding:10px; height:23px; border-top-left-radius: 5px; border-top-right-radius: 5px}
            .inner-body-box{overflow:auto !important; max-height:530px; padding:0px 10px}
            .box-menu-item{margin-bottom:1px; padding:10px 35px 10px 10px; cursor:pointer; border : 1px solid #fff; width:128px;}
            .box-menu-link{color:#444 !important; text-shadow: -1px -1px 1px #fff, 1px 1px 1px #eee;}
            .box-menu-parent{list-style: none; margin:0px; padding:10px 0px; font-size: 12px; float:left; border-right:1px solid #ccc; max-width:175px; height:496px}
            .separator{border-top:1px solid #ccc; padding-bottom:8px; margin-top:10px;}
            .box-menu-item-hover{background-color: #fff; border: 1px solid #ccc; border-right-color: #fff; width:129px}
            .box-menu-item-selected{background-color: #fff; border: 1px solid #ccc; border-right-color: #fff; width:129px}
            .band-close, .band-close-help{float:right; font-size: 12px; margin-top: 5px; margin-right:5px; cursor:pointer}
            .fwb{font-weight: bold}
            .submenu{cursor:pointer;}
            .top-parent-menu{font-weight:bold; font-size:14px}
            .li-submenu{width:200px !important; padding:8px 8px 8px 8px; cursor:pointer; z-index:9500; margin-bottom:2px; border:1px solid #fff}
            .float-menu{min-width:150px; z-index:9400; position:absolute; display:none; border:1px solid #ccc; background-color: #eee; box-shadow: 0px 0px 5px #ccc; padding: 10px 20px}
            .search-selected{background-color: #ccc}
        </style>
        <script>
            jQuery(function() {
                if (jQuery.browser.msie) {
                    jQuery(".inner-body-box").css("height", 580);
                    jQuery(".box-menu-parent").css("height", 540);
                }
                ;

                if (jQuery.browser.webkit) {
                    jQuery("#inner-docs").css("max-height", 557);
                }

                if (jQuery.browser.opera) {
                    jQuery(".edit-documentation").css("margin-top", -15);
                    jQuery(".preview-documentation").css("margin-top", -30).css("margin-right", 50);
                }

                jQuery(".box-menu-item").hover(function() {
                    jQuery(this).addClass("box-menu-item-hover");
                }, function() {
                    jQuery(this).removeClass("box-menu-item-hover");
                });

                jQuery(".box-menu-item").click(function() {
                    jQuery(".div-menu").hide();
                    jQuery("#" + jQuery(this).attr("idmenu")).show();
                    jQuery("#menu-search-input").focus();
                    jQuery(".box-menu-item-selected").removeClass("box-menu-item-selected").find("a").css("fontWeight", "normal");
                    jQuery(this).addClass("box-menu-item-selected").find("a").css("fontWeight", "bold");
                });

                jQuery("#openMenu").click(function() {
                    jQuery(".block-box").fadeIn("medium", function() {
                        jQuery("#menu2").hide();
                        jQuery("#menu1").show("fast", function() {
                            jQuery("#menu-search-input").focus();
                        });
                        jQuery(".menu-box").css("top", jQuery(document).scrollTop() + 35).slideDown("medium");
                        jQuery(".block-box").height(jQuery("body").height() + 48);

                    });
                });

                jQuery("#help-contents").click(function() {
                    jQuery(".block-box").fadeIn("medium", function() {
                        jQuery(".help-box").css("top", jQuery(document).scrollTop() + 35).slideDown("medium");
                        jQuery(".block-box").height(jQuery("body").height() + 48);
                    });
                });

<?php if (isset($_SESSION["fl"]) && $_SESSION["fl"] == true): ?>
    <?php $_SESSION["fl"] = false; ?>
<?php endif; ?>

        jQuery(".block-box, .band-close").click(function() {
            jQuery(".menu-box").slideUp("medium", function() {
                jQuery(".block-box").fadeOut("medium");
            });

            jQuery(".help-box").slideUp("medium", function() {
                jQuery(".block-box").fadeOut("medium");
            });
        });

        jQuery(".li-submenu:not(.top-parent-menu)").mouseover(function() {
            jQuery(".li-submenu").css("backgroundColor", "#fff");
            jQuery(".li-submenu").css("boxShadow", "0px 0px 0px #fff");
            jQuery(".li-submenu").css("border", "1px solid #fff");
            jQuery(".li-submenu").find("div.float-menu").hide();

            jQuery(this).css("backgroundColor", "#eee");
            jQuery(this).css("boxShadow", "0px 0px 5px #ccc");
            jQuery(this).css("border", "1px solid #ccc");
            var position = jQuery(this).position();
            var floatMenu = jQuery(this).find("div.float-menu");

            if (jQuery(this).parent().attr("subMenuAligment") === "4")
            {
                floatMenu.css("left", position.left - jQuery(this).outerWidth() + 35);

                if (jQuery(this).attr("sequence") !== "14" && jQuery(this).attr("sequence") !== "13")
                    floatMenu.css("top", position.top);
                else
                    floatMenu.css("top", position.top - floatMenu.height() + 12);

                floatMenu.show();
            }
            else
            {
                floatMenu.css("left", position.left + jQuery(this).outerWidth());

                if (jQuery(this).attr("sequence") !== "13" && jQuery(this).attr("sequence") !== "12")
                    floatMenu.css("top", position.top);
                else
                    floatMenu.css("top", position.top - floatMenu.height() + 12);

                floatMenu.show();
            }
        });

        jQuery(".li-submenu").mouseout(function() {
            jQuery(".li-submenu").css("backgroundColor", "#fff");
            jQuery(".li-submenu").find("div.float-menu").hide();
            jQuery(".li-submenu").css("boxShadow", "0px 0px 0px #fff");
            jQuery(".li-submenu").css("border", "1px solid #fff");
        });

        jQuery(".li-submenu").click(function() {
            var url = jQuery(this).find("a").attr("href");

            document.location = url;
        });
    });
        </script>
        <div class="block-box bb"></div>
        <div class="menu-box">
            <div class="inner-menu-box">
                <div class="inner-band-box">
                    <span class="band-title">Tools Anugerah Group Management System</span>
                    <span class="band-title band-close">Close</span>
                </div>
                <div class="inner-body-box">
                    <div id="menu1">
                        <ul class="box-menu-parent">
                            <li idmenu="div-menu-search" class="box-menu-item box-menu-item-selected">
                                <a class="box-menu-link">
                                    <image style="vertical-align:middle; margin-top:-3px" src='<?php echo base_url() ?>style/layout/images/icons/search.png' /> Cari Menu
                                </a>
                            </li>
                            <li class="separator">
                                <a class="box-menu-link">

                                </a>
                            </li>
                            <?php $counter = 1 ?>
                            <?php foreach ($parent_menus->result() as $item): ?>
                            <li idmenu="div-menu-<?php echo $item->id_menu ?>" class="box-menu-item">
                                <a class="box-menu-link">
                                        <?php echo $item->menu ?>
                                </a>
                            </li>
                                <?php $counter++ ?>
                            <?php endforeach; ?>
                        </ul>
                        <div class="div-menu" style="max-height:200px; padding:10px 10px 10px 190px;" id="div-menu-search">
                            <div style='border-bottom:1px solid #ccc; padding-bottom: 10px; margin-bottom: 10px'>
                                <input value='Masukkan Keyword' type='text' id='menu-search-input' style='color:#888; border:1px solid #ccc; padding:5px; width:893px' />
                                <button id='menu-search-button' class='btn btn-primary btn-small' style='margin-top:-3px'>Search</button>
                            </div>
                            <div style='max-height:200px'>
                                <div style="padding:0px 5px 5px 5px; font-size: 11px; border:1px solid #ccc; background-color: #eee">Anda dapat menggunakan tombol panah &#8593; dan &#8595; untuk memilik menu dan tekan <span style="font-size:18px">&#8629;</span> (Enter) untuk menuju tool yang anda tuju pada hasil pencarian di bawah ini.</div>
                                <h4>Hasil Pencarian : </h4>
                                <div style='max-height:200px'>
                                    <ul id='search-result' class="box-menu-parent" style="max-height:200px; margin-left:20px; list-style-image:url('<?php echo base_url(); ?>style/layout/images/arrow.gif'); border-right:0px; margin-top:-10px; min-width:220px !important">
                                        <li>Masukkan <strong>keyword</strong>.</li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <script>
                            jQuery(function() {
                                jQuery("#menu-search-input").focus(function() {
                                    if (jQuery(this).val() === "Masukkan Keyword")
                                        jQuery(this).val("");
                                });

                                jQuery("#menu-search-input").blur(function() {
                                    if (jQuery(this).val() === "")
                                        jQuery(this).val("Masukkan Keyword");
                                });

                                jQuery("#menu-search-input").keypress(function(e) {
                                    if (e.keyCode === 38) {
                                        var first = jQuery("#search-result > .search-selected").first();

                                        if (first.prev().hasClass("search-result-list"))
                                            first.prev().addClass("search-selected");
                                        else
                                            jQuery("#search-result > li").last().addClass("search-selected");

                                        first.removeClass("search-selected");
                                    } else if (e.keyCode === 40) {
                                        var first = jQuery("#search-result > .search-selected").first();

                                        if (first.next().hasClass("search-result-list"))
                                            first.next().addClass("search-selected");
                                        else
                                            jQuery("#search-result > li").first().addClass("search-selected");

                                        first.removeClass("search-selected");

                                    }
                                    else if (e.keyCode === 13) {
                                        document.location = jQuery(".search-selected a").attr("href");
                                    }
                                });

                                jQuery("#menu-search-input").keyup(function(e) {

                                    var searchVal = jQuery(this).val();

                                    if (searchVal !== "")
                                    {
                                        if (e.keyCode !== 38 && e.keyCode !== 40 && e.keyCode !== 13)
                                        {
                                            jQuery("#search-result").html("");
                                            jQuery(".box-menu-parent .li-submenu").each(function(index) {
                                                if (jQuery(this).text().toLowerCase().indexOf(searchVal.toLowerCase()) !== -1)
                                                {
                                                    var text = jQuery(this).text();
                                                    var textFinal = text.toLowerCase().replace(searchVal.toLowerCase(), "<strong style='color:blue; border-bottom:1px dashed blue'>" + searchVal.replace(/^([a-z])|\s+([a-z])/g, function($1) {
                                                        return $1.toUpperCase();
                                                    }) + "</strong>");

                                                    jQuery("#search-result").append("<li class='search-result-list' style='padding:5px 0px'>" + jQuery(this).html().replace(jQuery.trim(jQuery(this).text()), textFinal.replace(/^([a-z])|\s+([a-z])/g, function($1) {
                                                        return $1.toUpperCase();
                                                    })) + "</li>");


                                                    jQuery("#search-result > li").first().addClass("search-selected");
                                                }
                                            });
                                        }
                                    }
                                    else
                                    {
                                        jQuery("#search-result").html("");
                                        jQuery("#search-result").append("<li>Tidak ada hasil, berikan <strong>keyword</strong>.</li>");
                                    }
                                });

                                jQuery("#menu-search-button").click(function() {
                                    jQuery("#search-result").html("");
                                    var searchVal = jQuery("#menu-search-input").val();

                                    if (searchVal !== "")
                                    {
                                        jQuery(".box-menu-parent .li-submenu:contains('" + searchVal + "')").each(function(index) {
                                            if (jQuery(this).text().toLowerCase().indexOf(searchVal.toLowerCase()) !== -1)
                                            {
                                                var text = jQuery(this).text();
                                                var textFinal = text.toLowerCase().replace(searchVal.toLowerCase(), "<strong style='color:blue; border-bottom:1px dashed blue'>" + searchVal.replace(/^([a-z])|\s+([a-z])/g, function($1) {
                                                    return $1.toUpperCase();
                                                }) + "</strong>");

                                                jQuery("#search-result").append("<li style='padding:5px 0px'>" + jQuery(this).html().replace(jQuery.trim(jQuery(this).text()), textFinal.replace(/^([a-z])|\s+([a-z])/g, function($1) {
                                                    return $1.toUpperCase();
                                                })) + "</li>");
                                            }
                                        });
                                    }
                                    else
                                    {
                                        jQuery("#search-result").append("Tidak ada hasil, berikan <strong>keyword</strong>.");
                                    }
                                });
                            });
                        </script>
                        <?php $counter2 = 1 ?>
                        <?php foreach ($parent_menus->result() as $item): ?>
                        <div class="div-menu" style="padding:10px 10px 10px 190px; display:none" id="<?php echo "div-menu-" . $item->id_menu ?>">
                                <?php
                                $menus_raw = $this->db->query("select * from mt_menu where id_menu_induk is not null and is_sub_menu is null and id_menu_induk = $item->id_menu AND is_active != 0 order by urutan");
                                $menus_raw2 = array_chunk($menus_raw->result(), 13, true);
                                ?>
                                <?php $counter = 1 ?>
                                <?php foreach ($menus_raw2 as $menus): ?>
                            <ul subMenuAligment="<?php echo $counter ?>" class="box-menu-parent" style="margin-left:20px; list-style-image:url('<?php echo base_url(); ?>style/layout/images/arrow.gif'); border-right:0px; margin-top:-10px; min-width:220px !important">
                                        <?php $count = 1; ?>
                                        <?php foreach ($menus as $menu): ?>
                                <li class="li-submenu" sequence="<?php echo $count ?>">
                                                <?php $submenu = $this->db->query("select * from mt_menu where id_menu_induk is not null and is_sub_menu is not null and id_menu_induk = $menu->id_menu AND is_active != 0 order by urutan") ?>
                                                <?php if ($submenu->num_rows() > 0): ?>
                                    <div class="float-menu">
                                        <ul style="list-style:none; margin-left:10px; padding-left:0px; list-style-image:url('<?php echo base_url(); ?>style/layout/images/arrow.gif');">
                                                            <?php foreach ($submenu->result() as $submenu2): ?>
                                            <li style="padding:5px">
                                                <a style="color:#333" href="<?php echo str_replace("{root}", base_url(), $submenu2->link) ?>"><?php echo $submenu2->menu ?></a>
                                            </li>
                                                            <?php endforeach; ?>
                                        </ul>
                                    </div>
                                    <span class="submenu"><?php echo $menu->menu ?></span><br/>
                                                <?php else: ?>
                                    <a style="color:#333" href="<?php echo str_replace("{root}", base_url(), $menu->link) ?>"><?php echo $menu->menu ?></a>
                                                <?php endif; ?>
                                </li>
                                            <?php $count++; ?>
                                        <?php endforeach; ?>
                            </ul>
                                    <?php $counter++ ?>
                                <?php endforeach; ?>
                        </div>
                            <?php $counter2++ ?>
                        <?php endforeach; ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="help-box">
            <div class="inner-menu-box">
                <div class="inner-band-box">
                    <span class="band-title">Dokumentasi</span>
                    <span class="band-title band-close-help">Close</span>
                </div>
                <?php
                global $menu;
                $rand = mt_rand(100, 10000);
                ?>
                <div class="inner-body-box" id="inner-docs" style="padding:0px; max-height:530px">
                    <div style="border:1px solid #eee;">
                        <div style="border-bottom:1px solid #eee; padding:20px; ">
                            <span style="font-weight:bold; font-size: 14px"><?php echo preg_match("#^Menu#i", $menu->menu) ? $menu->menu : $menu->menu ?></span>
                            <?php if(IDDIVISI == 4): ?>
                            <button class="edit-documentation btn btn-primary btn-mini" style="float:right; margin-top:-3px">Edit</button>
                            <button class="preview-documentation btn btn-primary btn-mini" style="display:none; float:right; margin-top:-3px; margin-right:10px">Preview</button>
                            <?php endif; ?>
                        </div>
                        <div id="doc-content">
                            <div style="padding:10px 20px; font-size:12px !important; line-height: 1.8 !important; text-align: justify" id="contentd">
                                <p><?php echo $menu->dokumentasi_teknis_singkat == "" ? "Tidak ada Dokumentasi" : $menu->dokumentasi_teknis_singkat ?></p>
                            </div>
                        </div>
                        <style>
                            #contentd, #contentd p{font-size:12px !important; line-height: 1.8 !important; text-align: justify}
                        </style>
                        <div style="display:none;" id="doc-edit">
                            <div style="padding:10px 20px; font-size:12px; z-index: 999999">
                                <textarea style="width:100%; height:400px; resize: none; z-index: 999999" id="documentation-content-<?php echo $rand ?>" name="documentation-content"><?php echo $menu->dokumentasi_teknis_singkat == "" ? "Tidak ada Dokumentasi" : $menu->dokumentasi_teknis_singkat ?></textarea>
                            </div>
                            <script type="text/javascript">

                                var recent_content = '<?php echo $menu->dokumentasi_teknis_singkat == "" ? "Tidak ada Dokumentasi" : str_replace("\n", "", $menu->dokumentasi_teknis_singkat) ?>';
                                jQuery(function() {
                                    tinyMCE.init({
                                        mode: "exact",
                                        elements: "documentation-content-<?php echo $rand ?>",
                                        theme: "advanced",
                                        plugins: "autolink,lists,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
                                        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,|,outdent,indent,blockquote,|,print,|,ltr,rtl",
                                        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo,forecolor,backcolor,|,link,unlink,anchor,image,cleanup,help,code,|,preview",
                                        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,fullscreen",
                                        theme_advanced_buttons4: "",
                                        theme_advanced_toolbar_location: "top",
                                        theme_advanced_toolbar_align: "left",
                                        theme_advanced_statusbar_location: "bottom",
                                        theme_advanced_resizing: true,
                                        content_css: "",
                                        entity_encoding: "named"
                                    });

                                    jQuery(".edit-documentation").click(function(){
                                        if(jQuery(this).text() === "Edit" || jQuery(this).text() === "Continue Edit >>")
                                        {
                                            jQuery("#doc-content").hide();
                                            jQuery(this).text("Save");
                                            jQuery("#doc-edit, .preview-documentation").show();
                                        }
                                        else
                                        {
                                            var content = tinyMCE.get('documentation-content-<?php echo $rand ?>').getContent();

                                            jQuery("#contentd").html(content);

                                            jQuery.post("<?php echo base_url() . "index.php/admin/documentation_edit/" . $menu->id_menu ?>", {isi : content}, function(response){
                                                if(response === "1")
                                                {
                                                    alert("Dokumentasi telah berhasil diubah.");
                                                    recent_content = content;
                                                    jQuery("#doc-edit, .preview-documentation").hide();
                                                    jQuery(".edit-documentation").text("Edit");
                                                    jQuery("#doc-content").show();
                                                }
                                                else
                                                {
                                                    alert("Dokumentasi gagal diubah!, ulangi menyimpan sekali lagi.");
                                                }
                                            });
                                        }
                                    });

                                    jQuery(".preview-documentation").click(function(){
                                        jQuery("#contentd").html(tinyMCE.get('documentation-content-<?php echo $rand ?>').getContent());

                                        jQuery("#doc-edit, .preview-documentation").hide();
                                        jQuery(".edit-documentation").text("Continue Edit >>");
                                        jQuery("#doc-content").show();
                                    });

                                    jQuery(".block-box, .band-close-help").click(function() {
                                        jQuery("#contentd").html(recent_content);
                                        tinyMCE.get('documentation-content-<?php echo $rand ?>').setContent(recent_content);


                                        jQuery(".help-box").slideUp("medium", function() {
                                            jQuery(".block-box").fadeOut("medium");
                                        });
                                    });
                                });
                            </script>
                        </div>
                    </div>
                </div>
            </div>
        </div>